package com.liang.thread;

import com.liang.service.impl.MovieTypeServiceImpl;
import com.liang.service.impl.UserServiceImpl;
import java.math.BigInteger;

public class ThreadA implements Runnable{
    //电影 id ，用户id，主线程标志位
    private static int movieId;
    private static int userId;
    private static boolean flag=true;
    //该A线程的构造方法
    public ThreadA(int movieId,int userId) {
        this.movieId=movieId;
        this.userId=userId;
    }
    //线程方法体
    public void run() {
        UserServiceImpl userService = new UserServiceImpl();
        MovieTypeServiceImpl movieTypeService = new MovieTypeServiceImpl();
        //通过Movieid的到movietype的数组
        BigInteger[] movieType = movieTypeService.getMovieType(movieId);
        //把用户id转为BigInteger类型
        BigInteger i = BigInteger.valueOf(userId);
        //得到更新信息
        String s = userService.updateUser(i, movieType);
        System.out.println(s);
        System.out.println("A线程执行完");
        this.flag=false;
    }
    //得到标志位方法
    public boolean getFlag(){
        return flag;
    }
}


